﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HML.Demo
{
    public partial class TabControlPlus全局按钮EffectForm : ItemFormTemplate
    {
        public TabControlPlus全局按钮EffectForm()
        {
            InitializeComponent();
            this.Load += new System.EventHandler(this.Form_Load);
            this.Shown += new System.EventHandler(this.Form_Shown);
        }

        #region 实现

        public override ItemFormTemplateViewObject AsynchRequestTask(ItemFormTemplateViewObject view)
        {
            System.Threading.Thread.Sleep(300);
            view.ViewData = DemoHelper.GetDescription(AppDomain.CurrentDomain.BaseDirectory + "例子\\控件效果\\选项卡\\TabControlPlus全局按钮EffectForm.rtf");
            return view;
        }

        public override void DataBind(ItemFormTemplateViewObject viewObject)
        {
            this.introduceBrowser.Rtf = viewObject.ViewData.ToString();
        }

        public override void ShowView()
        {
            base.ShowView();
        }

        public override void HideView()
        {
            base.HideView();
        }

        public override void CloseView()
        {
            base.CloseView();
        }

        #endregion

        #region 属性面板

        private void Form_Load(object sender, EventArgs e)
        {
            this.controlContainer.SizeChanged += this.ControlContainer_SizeChanged;

            TabControlPlusGlobalButtton globalButtton_setting = new TabControlPlusGlobalButtton();
            globalButtton_setting.LRMargin = new LRMargin(6, 6);
            globalButtton_setting.ImageEnter = global::HML.Demo.Properties.Resources.Control_TabControlPlus全局按钮Effect_Settings;
            globalButtton_setting.ImageNormal = global::HML.Demo.Properties.Resources.Control_TabControlPlus全局按钮Effect_Settings;
            globalButtton_setting.Key = "setting";
            this.demo_control.TabBar.GlobalButttons.Add(globalButtton_setting);
            this.demo_control.TabBar.GlobalButttons["setting"].GlobalButttonClick += this.Demo_control_setting_GlobalCustomButttonClick;

            TabControlPlusGlobalButtton globalButtton_application = new TabControlPlusGlobalButtton();
            globalButtton_application.LRMargin = new LRMargin(6, 6);
            globalButtton_application.ImageEnter = global::HML.Demo.Properties.Resources.Control_TabControlPlus全局按钮Effect_Application;
            globalButtton_application.ImageNormal = global::HML.Demo.Properties.Resources.Control_TabControlPlus全局按钮Effect_Application;
            globalButtton_application.Key = "application";
            this.demo_control.TabBar.GlobalButttons.Add(globalButtton_application);
            this.demo_control.TabBar.GlobalButttons["application"].GlobalButttonClick += this.Demo_control_application_GlobalCustomButttonClick;

        }

        private void Form_Shown(object sender, EventArgs e)
        {
            this.splitContainer.SplitterDistance = Math.Max(this.splitContainer.Width / 4, this.splitContainer.Width - MainForm.GlobalSplitWidth);
            this.splitContainer.SplitterMoved += this.SplitContainer_SplitterMoved;

            MainForm.LoadAssistTabControl(this.assistTabControl);
        }

        private void SplitContainer_SplitterMoved(object sender, SplitterEventArgs e)
        {
            SplitContainer control = (SplitContainer)sender;
            MainForm.GlobalSplitWidth = this.splitContainer.Width - control.SplitterDistance;
        }

        private void ControlContainer_SizeChanged(object sender, EventArgs e)
        {
            Panel control = (Panel)sender;
            this.demo_control.Location = new Point((control.Width - this.demo_control.Width) / 2, (control.Height - this.demo_control.Height) / 2);
        }

        private void Demo_control_setting_GlobalCustomButttonClick(object sender, TabControlPlusGlobalButttonEventArgs e)
        {
            MessageBox.Show("点击了setting按钮");
        }

        private void Demo_control_application_GlobalCustomButttonClick(object sender, TabControlPlusGlobalButttonEventArgs e)
        {
            MessageBox.Show("点击了application按钮");
        }
        #endregion

    }
}
